34 lines
1.5 KiB
MQL5
34 lines
1.5 KiB
MQL5
//+------------------------------------------------------------------+
| |
//| SamplePendingStrategy.mqh |
| |
//| Copyright 2025, MetaQuotes Ltd. |
| |
//| https://www.mql5.com |
| |
//+------------------------------------------------------------------+
| |
#property copyright "Copyright 2025, MetaQuotes Ltd."
| |
#property link "https://www.mql5.com"
| |
#property version "1.00"
| |
| |
#include "AbstractStrategy.mqh"
| |
#include "../Events/Events/MarketStructEvent.mqh"
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
class SamplePendingStrategy : public AbstractStrategy
| |
{
| |
public:
| |
virtual void OnEvent(AbstractEvent* event) override
| |
{
| |
if(event.GetType() != ANALYSIS)
| |
return;
| |
MarketStructEvent* sig = (MarketStructEvent*)event;
| |
| |
// Example: place a buy stop at the current bar high + some offset
| |
double entryPrice = sig.GetPrice() + 50000 * _Point; // 50 points above trigger
| |
double sl = entryPrice - 10000 * _Point;
| |
double tp = entryPrice + 20000 * _Point;
| |
| |
// Publish signal with ORDER_TYPE_BUY_STOP
| |
PublishSignal(sig.GetSymbolName(), 1, entryPrice, sl, tp, sig.GetTimestamp(), ORDER_TYPE_BUY_STOP);
| |
}
| |
};
| |
//+------------------------------------------------------------------+
|