2026-11-20 11:46:31 +00:00 | | |
|
| | | #property strict
|
| | | #property version "1.00"
|
| | | #property description "Kastakar Marathi Forex Algo - Demo Only"
|
2026-11-18 06:16:20 +00:00 | | |
|
| | | #include <Trade/Trade.mqh>
|
| | | CTrade trade;
|
| | |
|
| | | input double LotSize = 0.01;
|
| | | input int FastEMA = 9;
|
| | | input int SlowEMA = 21;
|
2026-11-20 11:46:31 +00:00 | | | input int StopLossPoints = 300;
|
| | | input int TakeProfitPoints = 450;
|
| | | input ulong MagicNumber = 20261120;
|
2026-11-18 06:16:20 +00:00 | | |
|
2026-11-20 11:46:31 +00:00 | | | int fastHandle;
|
| | | int slowHandle;
|
| | | datetime lastBarTime = 0;
|
2026-11-18 06:16:20 +00:00 | | |
|
| | | int OnInit()
|
| | | {
|
2026-11-20 11:46:31 +00:00 | | | trade.SetExpertMagicNumber(MagicNumber);
|
| | |
|
| | | fastHandle = iMA(_Symbol, PERIOD_M5, FastEMA,
|
| | | 0, MODE_EMA, PRICE_CLOSE);
|
2026-11-18 06:16:20 +00:00 | | |
|
2026-11-20 11:46:31 +00:00 | | | slowHandle = iMA(_Symbol, PERIOD_M5, SlowEMA,
|
| | | 0, MODE_EMA, PRICE_CLOSE);
|
| | |
|
| | | if(fastHandle == INVALID_HANDLE ||
|
| | | slowHandle == INVALID_HANDLE)
|
2026-11-18 06:16:20 +00:00 | | | return INIT_FAILED;
|
| | |
|
| | | return INIT_SUCCEEDED;
|
| | | }
|
| | |
|
| | | void OnTick()
|
| | | {
|
2026-11-20 11:46:31 +00:00 | | | datetime barTime = iTime(_Symbol, PERIOD_M5, 0);
|
| | |
|
| | | if(barTime == lastBarTime)
|
| | | return;
|
| | |
|
| | | lastBarTime = barTime;
|
| | |
|
2026-11-18 06:16:20 +00:00 | | | if(PositionSelect(_Symbol))
|
| | | return;
|
| | |
|
| | | double fast[2], slow[2];
|
| | |
|
2026-11-20 11:46:31 +00:00 | | | if(CopyBuffer(fastHandle, 0, 1, 2, fast) != 2)
|
| | | return;
|
| | |
|
| | | if(CopyBuffer(slowHandle, 0, 1, 2, slow) != 2)
|
| | | return;
|
| | |
|
| | | // BUY signal: EMA 9 crosses above EMA 21
|
| | | if(fast[0] <= slow[0] && fast[1] > slow[1])
|
| | | {
|
| | | double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
|
| | | double sl = ask - StopLossPoints * _Point;
|
| | | double tp = ask + TakeProfitPoints * _Point;
|
| | |
|
| | | trade.Buy(LotSize, _Symbol, 0, sl, tp,
|
| | | "Kastakar BUY");
|
| | | }
|
2026-11-18 06:16:20 +00:00 | | |
|
2026-11-20 11:46:31 +00:00 | | | // SELL signal: EMA 9 crosses below EMA 21
|
| | | if(fast[0] >= slow[0] && fast[1] < slow[1])
|
| | | {
|
| | | double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
|
| | | double sl = bid + StopLossPoints * _Point;
|
| | | double tp = bid - TakeProfitPoints * _Point;
|
| | |
|
| | | trade.Sell(LotSize, _Symbol, 0, sl, tp,
|
| | | "Kastakar SELL");
|
| | | }
|
| | | }
|
| | |
|
| | | void OnDeinit(const int reason)
|
| | | {
|
| | | IndicatorRelease(fastHandle);
|
| | | IndicatorRelease(slowHandle);
|
| | | }
|