Hi
I need your help with this code i need when my ( fastmaArray[0] < slowmaArray[0]) fastmaArray this is my 5 simple MA and slowmaArray this is my 10 MA .
and they cross i need it to wait for the value of my MACD to reach below zero to sell.
I manged to make it sell when they cross and at the same time my MACD reach below zero I did not wanted like this i need it when cross it has to wait for my MACD to enter sell.
Please Help.
you are trying to bid with ask price
double bid = SymbolInfoDouble(_Symbol,SYMBOL_ASK);
you are trying to bid with ask price
Oh i forgot to change it thank you :)))) ...
back to my main issue see this screenshot the two ma crossed over and the macd <0 but no sell order was taken whats wrong with my code
Hi
if(fastmaArray[0] < slowmaArray[0] && fastmaArray[1] > slowmaArray[1]&& MacdValue<0){ printf("sell"); //sell order double bid = SymbolInfoDouble(_Symbol,SYMBOL_ASK); double sl = bid -50 * SymbolInfoDouble(_Symbol,SYMBOL_POINT); double tp = bid +200 * SymbolInfoDouble(_Symbol,SYMBOL_POINT); trade.Sell(1,_Symbol,bid,sl,tp,"sell trade"); }
Please Help.
is that all your code?
is that all your code?
#include <Trade/Trade.mqh> CTrade trade; int OnInit(){ return(INIT_SUCCEEDED); } void OnDeinit(const int reason) { } void OnTick(){ static datetime timestamp; datetime time = iTime(_Symbol,PERIOD_CURRENT,0); if(timestamp != time){ timestamp = time; // fast moving average static int handlefastma = iMA(_Symbol,PERIOD_CURRENT,14,0,MODE_SMA,PRICE_CLOSE); double fastmaArray[]; CopyBuffer(handlefastma,0,1,4,fastmaArray); ArraySetAsSeries(fastmaArray,true); //slow moving average static int handleslowma = iMA(_Symbol,PERIOD_CURRENT,28,0,MODE_SMA,PRICE_CLOSE); double slowmaArray[]; CopyBuffer(handleslowma,0,1,4,slowmaArray); ArraySetAsSeries(slowmaArray,true); //macd static int handleMacd = iMACD(_Symbol,PERIOD_CURRENT,12,26,9,PRICE_CLOSE); double macdArray []; CopyBuffer(handleMacd,0,0,3,macdArray); ArraySetAsSeries(macdArray,true); double MacdValue=(macdArray[1]); //buy if(fastmaArray[0] > slowmaArray[0] && fastmaArray[1] < slowmaArray[1]&& fastmaArray[2] < slowmaArray[2]){ if(MacdValue>0.0) printf("buy"); // buy order double ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK); double sl = ask -300 * SymbolInfoDouble(_Symbol,SYMBOL_POINT); double tp = ask +500 * SymbolInfoDouble(_Symbol,SYMBOL_POINT); trade.Buy(1,_Symbol,ask,sl,tp,"buy trade"); } //sell if(fastmaArray[0] < slowmaArray[0] && fastmaArray[1] > slowmaArray[1]&& fastmaArray[2] > slowmaArray[2]){ if(MacdValue<0.0) printf("sell"); //sell order double bid = SymbolInfoDouble(_Symbol,SYMBOL_BID); double sl = bid -300 * SymbolInfoDouble(_Symbol,SYMBOL_POINT); double tp = bid +500 * SymbolInfoDouble(_Symbol,SYMBOL_POINT); trade.Sell(1,_Symbol,bid,sl,tp,"sell trade"); } } }
Oh i forgot to change it thank you :)))) ...
back to my main issue see this screenshot the two ma crossed over and the macd <0 but no sell order was taken whats wrong with my code
1. there is no expert working on your chart :)
2. if actually was worked,
if(fastmaArray[0] < slowmaArray[0] && fastmaArray[1] > slowmaArray[1]&& fastmaArray[2] > slowmaArray[2]){ if(MacdValue<0.0)
crossing ma s in [0] bar macdvalue was not <0.0 ( it seems so on the graph )
all crossing condition and macd position might be at the same time ( bar )
1. there is no expert working on your chart :)
2. if actually was worked,
crossing ma s in [0] bar macdvalue was not <0.0 ( it seems so on the graph )
all crossing condition and macd position might be at the same time ( bar )
Of course the conditions are not met on the screenshot.
I think you need to learn more from
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
I need your help with this code i need when my ( fastmaArray[0] < slowmaArray[0]) fastmaArray this is my 5 simple MA and slowmaArray this is my 10 MA .
and they cross i need it to wait for the value of my MACD to reach below zero to sell.
I manged to make it sell when they cross and at the same time my MACD reach below zero I did not wanted like this i need it when cross it has to wait for my MACD to enter sell.
Please Help.