Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I am trying to create a simple pyramid code with up to 6 cumulative entry orders and exiting with different/independent profit targets for each entry. The entries are triggered by a percentual retreat of the market. Example:
Entry1 at (High - 2%)
Entry2 at (Entry1-2%)
Entry3 at (Entry2-2%)
......
Exit1 at Entry1 + Profit Target 1
Exit1 at Entry2 + Profit Target 2
...
Developed this code which doesnt work properly namely: a) Too much orders withoud respecting the percentual retreat and
b) Sell orders not respecting the Profit Target defined ( Loss instead of profit)
I would be very much obliged if someone could help me on this. Thanks
[IntrabarOrderGeneration = false]
inputs:
PctPullBack( 1 ) , PositionBasis( False ), HD( 0 ), N(0.1), Capital (100000), Amount1 (1000), Price (Close) , // Profit target for first entry
Amount2(1000) , Amount3(1000), Amount4(1000), Amount5(1000), Amount6(1000); // Profit target for other entries
Buy ( "ScaleIn 1" ) next bar at HOD * ( 1 - PctPullBack * .01 ) Limit ;
Amt1=Avgentryprice+Amount1*Avgentryprice/Capital ;// set profit tartet for 1st entry based on close of bar, not entryPrice end;
Buy ( "ScaleIn 2" ) next bar at HOD * ( 1 - (1+N)* PctPullBack * .01 ) Limit ;
Amt2=Avgentryprice+Amount2*Avgentryprice/Capital; // set profit tartet for 2nd entry based on close of bar, not entryPrice end;
Buy ( "ScaleIn 3" ) next bar at HOD * ( 1 - (1+2*N) * PctPullBack * .01 ) Limit ;
Amt3=Avgentryprice+Amount3*Avgentryprice/Capital;
Buy ( "ScaleIn 4" ) next bar at HOD * ( 1 - (1+3*N) * PctPullBack * .01 ) Limit ;
Amt4=Avgentryprice+Amount4*Avgentryprice/Capital;
Buy ( "ScaleIn 5" ) next bar at HOD * ( 1 - (1+4*N) * PctPullBack * .01 ) Limit ;
Amt5=Avgentryprice+Amount5*Avgentryprice/Capital;
Buy ( "ScaleIn 6" ) next bar at HOD * ( 1 - (1+5*N) * PctPullBack * .01 ) Limit ;
Amt6=Avgentryprice+Amount6*Avgentryprice/Capital;
sell ("LX1") from entry("ScaleIn 1") next bar at Amt1 limit;
sell ("LX2") from entry("ScaleIn 2") next bar at Amt2 limit; // will exit independently of 1st entry
sell ("LX3") from entry("ScaleIn 3") next bar at Amt3 limit; // will exit independently of other entries
sell ("LX4") from entry("ScaleIn 4") next bar at Amt4 limit; // will exit independently of 2nd entry
sell ("LX5") from entry("ScaleIn 5") next bar at Amt5 limit; // will exit independently of 1st entry
sell ("LX6") from entry("ScaleIn 6") next bar at Amt6 limit; // will exit independently of 2nd entry
Can you help answer these questions from other members on NexusFi?
can you show an example of "a) Too much orders withoud respecting the percentual retreat and
b) Sell orders not respecting the Profit Target defined ( Loss instead of profit)" on chart and clarify how it should be instead in this situation?
Thanks for the tip. Thats my difficulty how to link each entry ("ScaleIn 1"), ("ScaleIn 2").. to the corresponding desired amount of profit Amt1, Amt2,....., that is what should be the correct code for Amt1, Amt2, in order that it links to the corresponding entry ("ScaleIn 1"),("ScaleIn 2"), and not to the previous or actual price Close ...
what code did you use to create this output? I suggested using the print statement as it might make sense to find out what values your code uses internally for the orders, to find out what you need to change to get the results you want.
What is the value within your code for "Avgentryprice" for example on the bar where you enter?
The code is very simple but doesnt work properly because each entry ("ScaleIn 1" and "ScaleIn 2") are not linked with the desired Profit Tareget Price Amt1 and Amt2.
inputs:
PctPullBack( 1 ) , PositionBasis( False ), HD( 0 ), N(0.1), Capital (100000), Amount1 (1000), Price (Close) ,
Amount2(1000) ;// Amount1 and Amount2 are the Profit target
variables: HOD (0),Amt1(0),Amt2(0);
HOD = HighD( HD );
If CurrentBar> 1 then
Buy ( "ScaleIn 1" ) next bar at HOD * ( 1 - PctPullBack * .01 ) Limit ;
Amt1=Close+Amount1*Close/Capital ;// set profit tartet for 1st entry based on close of bar, not entryPrice end;
Buy ( "ScaleIn 2" ) next bar at HOD * ( 1 - (1+N)* PctPullBack * .01 ) Limit ;
Amt2=Close+Amount2*Close/Capital; // set profit tartet for 2nd entry based on close of bar, not entryPrice end;
sell ("LX1") from entry("ScaleIn 1") next bar at Amt1 limit;
sell ("LX2") from entry("ScaleIn 2") next bar at Amt2 limit; // will exit independently of 1st entry