Simple Coding Help - No Promise.

CougarTrader

Well-Known Member
Hi @Happy_Singh and other experts..
does static variable retains it's value across charts..
How come you are interested in AmiBroker now???

1570829685526.png


To all the big-shots participating here, STOP using pirated versions of AmiBroker. Piracy is a crime and you can be traced.
 
I never said this is written by me. I am not sure, where I saw this code, a lot of googling perhaps. I found it interesting and wanted to add Developing CPR in the same as mentioned by Frank Ochoa in his book. I have no intention of hijacking and taking credit for anyone's effort. I am sorry if I have offended you in any way.
 
A lot of heated words here, and a lot of reported posts.

The reported posts have been deleted and I have advised restraints on some members.

I request all the readers, specially the thread starters, to immediately report any off-topic posts immediately.

@CougarTrader , you have done a commendable job of noticing Amibroker pirates. I request that in future, when you notice any such posts, just report them to the mods instead of replying to those posts.
 
Cougar Bro it is great that you have highlighted the issues about Ami Piracy in a separate thread.However pursuing every individual in this forum on every thread like some folks might have just clicked on Like button reeks of trolling. There is thin line between highlighting the issues and vigilantism, for which a valuable member like you should not be excluded. I URGE to not keep following members into each and every thread and admonish them. I wish you all the best.

How come you are interested in AmiBroker now???

View attachment 38038

To all the big-shots participating here, STOP using pirated versions of AmiBroker. Piracy is a crime and you can be traced.
 

toocool

Well-Known Member
hi

can experts please code simple vwap/atp code which extends final vwap or atp price of current day to the next day as a line for full trading day , and so on ..............

regards
 

CougarTrader

Well-Known Member
Cougar Bro it is great that you have highlighted the issues about Ami Piracy in a separate thread.However pursuing every individual in this forum on every thread like some folks might have just clicked on Like button reeks of trolling. There is thin line between highlighting the issues and vigilantism, for which a valuable member like you should not be excluded. I URGE to not keep following members into each and every thread and admonish them. I wish you all the best.
The problem is that people shamelessly steal and still shout... It's no longer a question of being right or wrong! It's a question on everyone's character...
 
Dear Happy Singh

Iam a beginner and trying to learn backtesting

Pls let me know why this simple code does not work?

I have written detailed comments besides the code. I have been searching the forums for an understanding of the code issue but in vain.

Pls do check and advice where iam erring. Let me know if you require more info.

Thanks a lot !!

if(entrytrigger =2); /*pls refer to the last code comment, just before "Buy = Entry;". This is being checked because i do not want to take a new trade unless the previous trade's SL or Profit is hit.*/
{
Entry = Open < Close AND Ref(High,1) > High ; /*Simple buy rule to buy on a green candle and when the next bar crosses high of the green bar. The next bar can be a red bar but only condition is that it should cross the previous high. The buy will trigger only when the immediate next bar crosses the high of the green bar else the trade is off*/
if (Entry = True); /*iam checking whether there is an entry and if true then iam setting the SL and Profit target as per below codes. Unless there is an entry, there should not be any SL or Profit targets*/
{
SLLong = Low; /*SL is set at the low of the green bar*/
PRLong = High+((High-Low)*2); /*Profit target is set at twice the range of the green bar*/
entrytrigger = 1; /*iam setting this to control that the backtest engine does not take another entry unless either the SL is triggered or the profit target is hit.*/
}
}

if (Entry = True AND entrytrigger = 1); /*iam setting the condition to check whether the SL or Profit target is hit only when there is an entry is true and entrytrigger is set as 1*/
{
SLPRhit = IIf(High >= PRLong OR Low < SLLong,1,0); /* checking either SL or Profit is hit in subsequent bars
entrytrigger = IIf(SLPRhit=1,2,1); //Resetting the entry trigger to 2 once the SL or Profit is hit so that the next entry can be searched as per the first line of the code*/
}

Buy = Entry;
Sell = SLPRhit;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
 
Please re-read the basic sections in the manual / AFL reference
assignment operator is = where as
logical comparison operator is ==


ExRem removes all the extra buy/short signals


.
Yeah, such a novice Iam. Thanks !

Can you pls advice regarding how to identify the index of first bar? This is required since iam encountering error now (after rectifying the stated mistake) that I have not initialized "entrytrigger" in the very first line of the code which is "if(entrytrigger ==2);". I have checked on BarIndex, Barcount, Cum etc but not getting to know how to use them here.

I want to instruct backtesting engine to check whether it is encountering the first bar and if yes, initialise the variable "entrytrigger" and later on the rest of the code should assign value to it as per the flow, which was mentioned in my previous post
 

Similar threads

Broker Special Offers

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?