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,536 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

  #1 (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

So I have finally decided to try my hand at EasyLanguage / PowerLanguage.

Sometime I will get around to doing one of the courses on it, but for now I am just doing some self-teaching.

I have run into a strange issue. I am trying to create a PaintBar that will change color if the price is above the PSAR vs below the PSAR.

Here is the code of what I have and maybe somebody could help me out with what I am doing wrong.

Variables:
var0( 0 ) ,
var1( 0 ) ,
var2( 0 ) ,
var3( 0 ) ;



if Close > ParabolicSAR( .02 , .2 , var0 , var1 , var2 , var3 ) then begin
PlotPaintBar( High , Low , Open , Close , "" , White ) ;
end

If Close < ParabolicSAR( .02 , .2 , var0 , var1 , var2 , var3 ) then begin
PlotPaintBar(High , Low , Open , Close "" , White ) ;
end

First of all, this will not compile. It says that it does not expect the second "if" statement. Therefore, my first question is what is wrong with this keeping it from accepting the second If statement.

The second issue is that, if I take out the second If statement, then it has no problems compiling - but, it colors every single bar as white. What have I done wrong so that every bar is white rather than only the bars that are above the PSAR.

If I take out the first If statement and only choose to color the bars that are below the PSAR then none of the bars will color.

If you need it, here is the ParabolicSAR function code:

inputs: AfStep( 0.02), AfLimit( 0.2 ) ;
variables: var0( 0 ), var1( 0 ), var2( 0 ), var3( 0 ), var4( "" ) ;

Value1 = ParabolicSAR( AfStep , AfLimit , var0 , var1 , var2 , var3 ) ;

Plot1( var0, "ParCl" ) ;


if var3 = 1 then
Alert( "Bullish reversal" )
else if var3 = -1 then
Alert( "Bearish reversal" ) ;


Thank you very much for your help.

There are a few items that I have that will come after this.

Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Build trailing stop for micro index(s)
Psychology and Money Management
Futures True Range Report
The Elite Circle
Exit Strategy
NinjaTrader
Are there any eval firms that allow you to sink to your …
Traders Hideout
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
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
37 thanks
NexusFi site changelog and issues/problem reporting
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks
  #3 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,647 since Jul 2012
Thanks Given: 1,890
Thanks Received: 7,338



JGSmith View Post
So I have finally decided to try my hand at EasyLanguage / PowerLanguage.

Sometime I will get around to doing one of the courses on it, but for now I am just doing some self-teaching.

I have run into a strange issue. I am trying to create a PaintBar that will change color if the price is above the PSAR vs below the PSAR.

Here is the code of what I have and maybe somebody could help me out with what I am doing wrong.

Variables:
var0( 0 ) ,
var1( 0 ) ,
var2( 0 ) ,
var3( 0 ) ;



if Close > ParabolicSAR( .02 , .2 , var0 , var1 , var2 , var3 ) then begin
PlotPaintBar( High , Low , Open , Close , "" , White ) ;
end

If Close < ParabolicSAR( .02 , .2 , var0 , var1 , var2 , var3 ) then begin
PlotPaintBar(High , Low , Open , Close "" , White ) ;
end

First of all, this will not compile. It says that it does not expect the second "if" statement. Therefore, my first question is what is wrong with this keeping it from accepting the second If statement.

The second issue is that, if I take out the second If statement, then it has no problems compiling - but, it colors every single bar as white. What have I done wrong so that every bar is white rather than only the bars that are above the PSAR.

If I take out the first If statement and only choose to color the bars that are below the PSAR then none of the bars will color.

If you need it, here is the ParabolicSAR function code:

inputs: AfStep( 0.02), AfLimit( 0.2 ) ;
variables: var0( 0 ), var1( 0 ), var2( 0 ), var3( 0 ), var4( "" ) ;

Value1 = ParabolicSAR( AfStep , AfLimit , var0 , var1 , var2 , var3 ) ;

Plot1( var0, "ParCl" ) ;


if var3 = 1 then
Alert( "Bullish reversal" )
else if var3 = -1 then
Alert( "Bearish reversal" ) ;


Thank you very much for your help.

There are a few items that I have that will come after this.


1. Put a semicolon after every "end" statement (

2. You have both conditions painting the bar as white. Also, make sure ParabolicSAR is giving you correct values.



You don't need a course to learn Easy Language. Try these 2 guides. They are old, but if you follow the exercises, you'll get up to speed quickly, and for free.

Attached Thumbnails
Programming Newbie-el_essentials.pdf   Programming Newbie-el_functionsandreservedwords_ref.pdf  
Follow me on Twitter Reply With Quote
  #4 (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


kevinkdog View Post
1. Put a semicolon after every "end" statement (

2. You have both conditions painting the bar as white. Also, make sure ParabolicSAR is giving you correct values.



You don't need a course to learn Easy Language. Try these 2 guides. They are old, but if you follow the exercises, you'll get up to speed quickly, and for free.

haha, pretty dumb mistake about both conditions being white. LOL. Obviously I was working on that late last night.

Anyway, I will post the updated code. It has not changed anything so I think that it has to do with the PSAR giving the correct values. I will also post a pic of the chart. As far as I know, in the PSAR code, the only values that matter are the .02 & .2. Correct? From what I understand in the EasyLanguage dictionary that the other values are just for order entry/management.

Also, thanks a ton for the resources to learn EL. I will spend time on those.

Variables:
var0( 0 ) ,
var1( 0 ) ,
var2( 0 ) ,
var3( 0 ) ;



if Close > ParabolicSAR( .02 , .2 , var0 , var1 , var2 , var3 ) then begin
PlotPaintBar( High , Low , Open , Close , "" , White ) ;
end ;

If Close < ParabolicSAR( .02 , .2 , var0 , var1 , var2 , var3 ) then begin
PlotPaintBar(High , Low , Open , Close , "" , Magenta ) ;
end ;



Started this thread Reply With Quote
  #5 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,647 since Jul 2012
Thanks Given: 1,890
Thanks Received: 7,338

You are using the function incorrectly. Below is info from the Help file:

Returns (Integer)
The oParCl, OParOP, oPosition, oTransition output parameters return the parabolic stop values for the current day and the next bar, as well as the probable position of the market. The ParabolicSAR itself returns 1.

Parameters
Name
Type
Description

AfStep
Numeric
Sets the acceleration increment factor.

AfLimit
Numeric
Sets the acceleration limitation factor.

oParCl
Numeric
Outputs the parabolic stop value for the current bar.

oParOp
Numeric
Outputs the parabolic stop value for the next bar.

oPosition
Numeric
Outputs the potential market position. 1 for long, -1 for short.

oTransition
Numeric
Outputs if the current bar market position has changed. 1 or -1 for reversal days 0 for holding days.



Example
Vars: oParCl(0), oParOp(0), oPostion(0), oTransition(0);

Value1 = ParabolicSAR(0.02, 0.4, oParCl, oParOp, oPosition, oTransition);
Value2 = oParCl;
Value3 = oParOp;
Value4 = oPosition;
Value5 = oTransition;


Follow me on Twitter Reply With Quote
  #6 (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


kevinkdog View Post
You are using the function incorrectly. Below is info from the Help file:

Okay thanks.

Obviously there is still plenty more for me to learn as this information doesn't help me much.

I am actively going through the PDFs that you posted and will see if that information helps me.

Started this thread Reply With Quote
  #7 (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

Finally got that figured out. Now it works like a charm!

Here is my next question and I can not find the answer to this anywhere in any of the easy language docs.

This one also deals with PaintBars.

Now I would like to create a paint bar if the Aroon Up indicator = 100, Close > Open, and Close > keltner Channel. But, I only want it on the first candle that closes outside of the keltner channel. Basically it needs to close back inside of the keltner channel in order to "reset".

 
Code
if __AroonUp = 100 and
Close > KeltnerChannel and
Open > Close then
PlotPaintBar(Open,Low,High,Close,"",Magenta);
Clearly that part is quite straight forward.

But now I need to figure out how to just make the first occurrence of the close outside of the KeltnerChannel to the painted bar.

Any suggestions?

I really appreciate the help.

Started this thread Reply With Quote
  #8 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

JGSmith,

you can also google for EasyLanguage or PowerLanguage tutorials. There are some around that might help you, too.
Other than that you are already moving into the right direction. You best learn the language when you program it. Start simple and keep getting more complex. If you run into a problem there is always a helping hand here.

Regards,
ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #9 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

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


JGSmith View Post
Finally got that figured out. Now it works like a charm!

Here is my next question and I can not find the answer to this anywhere in any of the easy language docs.

This one also deals with PaintBars.

Now I would like to create a paint bar if the Aroon Up indicator = 100, Close > Open, and Close > keltner Channel. But, I only want it on the first candle that closes outside of the keltner channel. Basically it needs to close back inside of the keltner channel in order to "reset".

 
Code
if __AroonUp = 100 and
Close > KeltnerChannel and
Open > Close then
PlotPaintBar(Open,Low,High,Close,"",Magenta);
Clearly that part is quite straight forward.

But now I need to figure out how to just make the first occurrence of the close outside of the KeltnerChannel to the painted bar.

Any suggestions?

I really appreciate the help.


Follow me on Twitter Reply With Quote
Thanked by:
  #10 (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 can also google for EasyLanguage or PowerLanguage tutorials. There are some around that might help you, too.
Other than that you are already moving into the right direction. You best learn the language when you program it. Start simple and keep getting more complex. If you run into a problem there is always a helping hand here.

Regards,
ABCTG

Thanks a ton, ABCTG

Looks like we are practically neighbors. You are in Hamburg. I am often there as my wife's family is in Lübeck. Would be fun to meet up sometime.

Started this thread Reply With Quote




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