NexusFi: Find Your Edge


Home Menu

 





Programming Newbie


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one JGSmith with 9 posts (1 thanks)
    2. looks_two ABCTG with 6 posts (5 thanks)
    3. looks_3 kevinkdog with 2 posts (0 thanks)
    4. looks_4 LogicalTrader with 2 posts (1 thanks)
    1. trending_up 4,460 views
    2. thumb_up 7 thanks given
    3. group 3 followers
    1. forum 19 posts
    2. attach_file 6 attachments




 
Search this Thread

Programming Newbie

(login for full post details)
  #11 (permalink)
 
JGSmith's Avatar
 JGSmith 
Lübeck, Germany
 
Experience: Intermediate
Platform: NinjaTrader, MT4
Broker: FXCM, Interactive Brokers, Oanda
Trading: Forex
Posts: 151 since Aug 2013
Thanks Given: 61
Thanks Received: 55


ABCTG View Post
JGSmith,

you will need a flag for that. This is a variable you use to prevent the paintbar from plotting more than once.
The variable could be a Boolean variable i.e. true/false.

Something like this should work:

 
Code
Variables: HavePaintBar(false);

//the reset part:
if Close < KeltnerChannel and HavePaintBar then
HavePaintBar = false;

if __AroonUp = 100 and
Close > KeltnerChannel and
Open > Close and HavePaintBar = false then
begin
HavePaintBar = true;
PlotPaintBar(Open,Low,High,Close,"",Magenta);
end;
Regards,
ABCTG

Unfortunately, this didn't work. I will post some more details tomorrow to see if we can get this figured out. It may be something that plenty of people will find beneficial.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Request for MACD with option to use different MAs for fa …
NinjaTrader
Looking for an MQL4 MetaTrader programmer/coder
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
33 thanks
Daytrading ES & NQ
32 thanks
Battlestations: Show us your trading desks!
31 thanks
Spoo-nalysis ES e-mini futures S&P 500
28 thanks
Retail Trading As An Industry
25 thanks

(login for full post details)
  #12 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,429 since Apr 2013
Thanks Given: 479
Thanks Received: 1,619

Okay. I just posted the idea from the top of my head and didn't test it first.
If you post the whole code, I can take a look at it tomorrow as well.

Regards and a good night,
ABCTG


JGSmith View Post
Unfortunately, this didn't work. I will post some more details tomorrow to see if we can get this figured out. It may be something that plenty of people will find beneficial.


Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
(login for full post details)
  #13 (permalink)
LogicalTrader
Houston, TX
 
Posts: 294 since Aug 2013
Thanks Given: 1,420
Thanks Received: 757


In EasyLanguage, first occurrences of a condition being true or false can be derived by comparing the value of a variable set when the current bar is evaluated vs the value of the same variable set when the previous bar was evaluated.

For instance, if you store your condition (true/false) result in a variable "HavePaintBar" in your code - something like this:
 
Code
if (myCondition) then
HavePaintBar = True
Else
HavePaintBar = False;

Then to check if the condition became true for the first time, you could write something like this:
 
Code
If (HavePaintBar = True And HavePaintBar[1] = False) then
PlotPaintBar()...

The value evaluated for a variable for each previous bar can be accessed by using the [1], [2]... etc suffix as if the values are being stored in an array and you can access the value using the array index.

Hope this helps.

Reply With Quote
(login for full post details)
  #14 (permalink)
 
JGSmith's Avatar
 JGSmith 
Lübeck, Germany
 
Experience: Intermediate
Platform: NinjaTrader, MT4
Broker: FXCM, Interactive Brokers, Oanda
Trading: Forex
Posts: 151 since Aug 2013
Thanks Given: 61
Thanks Received: 55


ABCTG View Post
Okay. I just posted the idea from the top of my head and didn't test it first.
If you post the whole code, I can take a look at it tomorrow as well.

Regards and a good night,
ABCTG

Great, thanks so much. Your help has been invaluable toward my further understanding.


iNeo View Post
In EasyLanguage, first occurrences of a condition being true or false can be derived by comparing the value of a variable set when the current bar is evaluated vs the value of the same variable set when the previous bar was evaluated.

For instance, if you store your condition (true/false) result in a variable "HavePaintBar" in your code - something like this:

Thank you iNeo. This has helped to move things forward. From what I can see, it is better - but still not exact.

I am posting a pic and the code for what I have so far.

Important for anybody reading this and may say, "Wow, that code produced a really great buy signal!!" and then attempt to use it. There is still one very important parameter that is not entered into the code yet so it is not tradeable as it is. Secondly, I haven't seen this strategy work as well on Futures or Equities. It may work, but I have not been able to find other instruments besides certain FX pairs that it works on.

In the picture, you will see some Blue squares. These blue squares are the ones that are correct - according to the current parameters. Those with the Red arrow above them are incorrect.



 
Code
input:
	thold ( 20 ) ,
	length ( 14 ) ,
	CandleColorLong( white ) ,
	CandleColorShort( Magenta ), 
	AroonLength( 14 ),
	KCATR( 1.5 ) ,
	KCLength( 20 ),
	MALength( 20 ), 
	AFStep( 0.02 ),
	AfLimit( 0.2 );

variables:
	var0( 0 ) ,
	var1( 0 ) ,
	var2( 0 ) ,
	var3( 0 ) ,
	HavePaintBar( false ) ;
	
Value1 = ParabolicSAR( AfStep , AfLimit , var0 , var1 , var2 , var3 ) ;


	if __AroonUp( AroonLength ) = 100 and
		Close > Open and 
		Close > KeltnerChannel(close , KCLength , KCATR ) and
		Close > Average( Close , MALength ) and 
		var3 <= 1 and
		(__AroonUp[1]( AroonLength ) <> 100 or
		Close[1] < Open[1] or
		Close[1] < KeltnerChannel(close , KCLength , KCATR )[1] or
		Close[1] < Average( Close , MALength )[1] or
		var3 <= 1 ) 
	then
		HavePaintBar = True 
	else
		HavePaintBar = False;
		
	If HavePaintBar = True and 
		HavePaintBar[1] = False then 			
		PlotPaintBar(High , Low , Open , Close , "" , CandleColorLong ) ;
First, is there someway that I have misunderstood what has been said already and that is causing me to not get the result that I am looking for?
Secondly, if I have understood everything correctly thus far, can you see the adjustments that I need to make?

I genuinely want to thank people for their help. This has been invaluable to my learning up this point.

Started this thread Reply With Quote
(login for full post details)
  #15 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,429 since Apr 2013
Thanks Given: 479
Thanks Received: 1,619

You are welcome.

Please check this code, I am using the close below the Keltner to reset the ability to look for a new paintbar.
If this doesn't do what you want, maybe you can post a screenshot that displays the bars this study shouldn't mark (just like you did with your study).

Regards,
ABCTG

 
Code
input:
	thold ( 20 ) ,
	length ( 14 ) ,
	CandleColorLong( white ) ,
	CandleColorShort( Magenta ), 
	AroonLength( 14 ),
	KCATR( 1.5 ) ,
	KCLength( 20 ),
	MALength( 20 ), 
	AFStep( 0.02 ),
	AfLimit( 0.2 );

variables:
	var0( 0 ) ,
	var1( 0 ) ,
	var2( 0 ) ,
	var3( 0 ) ,
	KeltnerValue(0),
	HavePaintBar( false ) ;
		
Value1 = ParabolicSAR( AfStep , AfLimit , var0 , var1 , var2 , var3 ) ;

KeltnerValue = KeltnerChannel(close , KCLength , KCATR );

//the reset part:
if Close < KeltnerValue and HavePaintBar then
HavePaintBar = false;

if __AroonUp( AroonLength ) = 100 and
	Close > Open and 
	Close > KeltnerValue and
	Close > Average( Close , MALength ) and 
	var3 <= 1 and
	(__AroonUp( AroonLength ) <> 100 or
	Close[1] < Open[1] or
	Close[1] < KeltnerValue[1] or
	Close[1] < Average( Close , MALength )[1] or
	var3 <= 1 ) 
then
	HavePaintBar = True;
	
If HavePaintBar = True and 
	HavePaintBar[1] = False then 			
	PlotPaintBar(High , Low , Open , Close , "" , CandleColorLong ) ;

Follow me on Twitter Reply With Quote
(login for full post details)
  #16 (permalink)
 
JGSmith's Avatar
 JGSmith 
Lübeck, Germany
 
Experience: Intermediate
Platform: NinjaTrader, MT4
Broker: FXCM, Interactive Brokers, Oanda
Trading: Forex
Posts: 151 since Aug 2013
Thanks Given: 61
Thanks Received: 55


ABCTG View Post
Please check this code, I am using the close below the Keltner to reset the ability to look for a new paintbar.
If this doesn't do what you want, maybe you can post a screenshot that displays the bars this study shouldn't mark (just like you did with your study).

That works like a charm!

So it looks like you added another variable: KeltnerValue.

So basically if I wanted to do this with another indicator then I would need to add a new variable and then assign that variable with a value then I do that fancy little if/then statement and it all works?

Started this thread Reply With Quote
(login for full post details)
  #17 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,429 since Apr 2013
Thanks Given: 479
Thanks Received: 1,619

Great. It didn't not work before, because in a previous post I just wrote "KeltnerChannel" without the inputs.
That's why it probably didn't compile on your end.

I just added the KeltnerValue variable so you don't have to call the same function three times in your code. Now it's only called one time and the value is assigned to the variable KeltnerValue.
You could do the same with the __AroonUp and the Average, as you call them twice, too.
With your study this isn't a problem, but every function call will add to the time the indicator takes for the calculations.
Your study will also become easier to maintain when all functions are called in one place and then stored within variables for further use (at least this is my experience).

Yes, it should work the same when you want to do it with another indicator.

Regards,
ABCTG


JGSmith View Post
That works like a charm!

So it looks like you added another variable: KeltnerValue.

So basically if I wanted to do this with another indicator then I would need to add a new variable and then assign that variable with a value then I do that fancy little if/then statement and it all works?


Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
(login for full post details)
  #18 (permalink)
 
JGSmith's Avatar
 JGSmith 
Lübeck, Germany
 
Experience: Intermediate
Platform: NinjaTrader, MT4
Broker: FXCM, Interactive Brokers, Oanda
Trading: Forex
Posts: 151 since Aug 2013
Thanks Given: 61
Thanks Received: 55

I just wanted to come on here and post a picture of the completed first phase of my very first indicator that I have written (with the exception of practice indicators while trying to learn)

This is the basis for a strategy that I trade very regularly and now I can just remove the indicators from my chart and have a nice clean and pretty screen.

After patting myself on the back for a little bit and reveling in this accomplishment - there will be plenty of more work to get the next phases completed.

Here is a picture of the work. (The arrows are not part of the indicator - they are just to make more obvious where the PaintBars are for the sake of this screenshot.)


Started this thread Reply With Quote
(login for full post details)
  #19 (permalink)
LogicalTrader
Houston, TX
 
Posts: 294 since Aug 2013
Thanks Given: 1,420
Thanks Received: 757

Good job.

Reply With Quote
(login for full post details)
  #20 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,429 since Apr 2013
Thanks Given: 479
Thanks Received: 1,619


Looks good, congratulations. As you are using Multicharts you can in fact let the indicator draw the arrows on the chart, too.
Arw_New, Arw_New_s or Arw_New_DT are the three reserved words that can draw a new arrow. You can change size, color and style with keywords words, too.



Regards,
ABCTG


JGSmith View Post
I just wanted to come on here and post a picture of the completed first phase of my very first indicator that I have written (with the exception of practice indicators while trying to learn)

This is the basis for a strategy that I trade very regularly and now I can just remove the indicators from my chart and have a nice clean and pretty screen.

After patting myself on the back for a little bit and reveling in this accomplishment - there will be plenty of more work to get the next phases completed.

Here is a picture of the work. (The arrows are not part of the indicator - they are just to make more obvious where the PaintBars are for the sake of this screenshot.)



Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:





Last Updated on September 4, 2013


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts