On Bar Close Code For Indicator

Back to topics list To post a new topic, please log in or register
avatar
4
bluerosetrader 2016.04.19 21:04
 

I have an indicator that gives a signal (arrow) if a set of conditions is met, however I have not been able to find the documentation for a BAR ON CLOSE option. Any thoughts/ideas on how to accomplish this. My dream will be to have the Input in that way I can choose weather I would like the BarOnClose or not, By the way I also would like that input for alarms. Any code ideas for any of these or where can I go for further reference.

Help will be greatly appreciated.

 


avatar
1197
FMIC 2016.04.19 22:52 #
 

Without any code we will not be able to help you!

We cannot read your mind nor do we know what kind of indicator you are talking about or how it even works.

Without more information, we will simply be guessing!

avatar
12985
WHRoeder 2016.04.20 03:23 #
 
bluerosetrader: I have an indicator that gives a signal (arrow) if a set of conditions is met, however I have not been able to find the documentation for a BAR ON CLOSE option.
"BAR ON CLOSE" is meaning less. Indicators draw all bars, meaningless.
avatar
4
bluerosetrader 2016.04.20 19:42 #
 
FMIC:

Without any code we will not be able to help you!

We cannot read your mind nor do we know what kind of indicator you are talking about or how it even works.

Without more information, we will simply be guessing!

Yes, you are right, I copied the code on my original post, will that be enough? I kind of need a BAR_ON_CLOSE before giving the signal, its not happening...
avatar
1197
FMIC 2016.04.20 20:13 #
 

No, it is not enough!

  1. Use the "SRC" button to add code to your post or add it as a file attachment.
  2. In the code you supplied, where is the code for the supposed "Arrow" you mentioned?
    1. Is it perhaps the "notifyAlert"?
    2. If so, what does it do? Where is the code for that?
  3. Explain what you mean by "BAR_ON_CLOSE".
    1. Are you asking about the chart "repainting"?
    2. Or are you asking if the alert can be given in reference to the previously closed bar?
  4. Pictures are worth a thousand words:
    1. Provide a Screen shot of what it does.
    2. Show what you want or expect it to do (use some kind of graphical annotations).

If you want help, don't be so secretive about it! If you don't open up and explain things, we cannot help.

PS! Something tells me you are a NinjaTrader programmer and you are looking for the equivalent to the "OnBarClose" event. Is that it? If so, MQL4 works differently, and you will have to explain exactly what you expect in order to find the best MQL4 approach for your requirements.

avatar
4
bluerosetrader 2016.04.20 21:00 #
 


Hello FMCI,

Yes I am a Ninja Trader, and yes I am looking for the OnBarClose equivalent. Thank you so much for your help. 

avatar
1197
FMIC 2016.04.20 23:25 #
 
bluerosetrader:

Hello FMCI,

Yes I am a Ninja Trader, and yes I am looking for the OnBarClose equivalent. Thank you so much for your help. 

MetaTrader's MQL4 language works differently to NinjaTrader and does not have OnBarClose. You have to learn to do things the MQL way.

I am not a NinjaTrader user and know nothing about its programming language. I simply used Google in order to try decipher what you may have wanted. However, it is not my responsibility to try guess what you want! You have to describe what it is that you are trying to achieve with your indicator, so that we can help you.

From what I can guess; you don't want the last and current bar to keep "repainting" because its current close price is constantly changing and therefore your alert keeps changing. However, that is how it is supposed to be in MetaTrader. The last bar is always in "flux". The equivalent of the "OnBarClose", is in MetaTrader, the equivalent to looking at the previous bar's data (i.e. the one just before the current one).

So instead of looking at the current bar (BUY[0] or SELL[0]) as a trigger for your Alert message, look at the previous bar (BUY[1] or SELL[1]). So, in essence if I understand your code correctly, in the "notifyAlert()" function, instead of the line "if( barNum != 0 ) return;" use:

if( barNum != 1 ) return;
avatar
4
bluerosetrader 2016.04.21 19:14 #
 
FMIC:

MetaTrader's MQL4 language works differently to NinjaTrader and does not have OnBarClose. You have to learn to do things the MQL way.

I am not a NinjaTrader user and know nothing about its programming language. I simply used Google in order to try decipher what you may have wanted. However, it is not my responsibility to try guess what you want! You have to describe what it is that you are trying to achieve with your indicator, so that we can help you.

From what I can guess; you don't want the last and current bar to keep "repainting" because its current close price is constantly changing and therefore your alert keeps changing. However, that is how it is supposed to be in MetaTrader. The last bar is always in "flux". The equivalent of the "OnBarClose", is in MetaTrader, the equivalent to looking at the previous bar's data (i.e. the one just before the current one).

So instead of looking at the current bar (BUY[0] or SELL[0]) as a trigger for your Alert message, look at the previous bar (BUY[1] or SELL[1]). So, in essence if I understand your code correctly, in the "notifyAlert()" function, instead of the line "if( barNum != 0 ) return;" use:

That seemed to do the trick thanks a lot...I am getting the signal once the bar closes...so far....thanks,...

 

Back to topics list  

To add comments, please log in or register