Simple Coding Help - No Promise.

dell

Well-Known Member
that could also be done...but for that some ownscale option would have to be used and show that with different scale

but won't it be confusing two sets of price bar in same pane?
yes sir , it will be clustered if both in same pane ...
can it be possible to have 3m for bnf and 5m for nifty in same pane , as nifty is less volatile than bnf , so a shifting upto 5m tf is better sir ....

so sir ,how to get 5tf of nifty chart as foreign price in 3m bnf pane ?
 

pratapvb

Well-Known Member
again can be done but more tricky need AFL

also the diff TF axis will not match so here vertical lines have been put to indicate day change

(have not shared this yet in any public forum)

 

dell

Well-Known Member
again can be done but more tricky need AFL

also the diff TF axis will not match so here vertical lines have been put to indicate day change

(have not shared this yet in any public forum)

sir , how many hands u have , yeh sab kay sab hands mujko de do dada , just joking

if u feels comfortable in sharing than , can u plz ......

i know time ,and hard work consumed in coding , it is easy to say to share it but one who code it , he knows the value of devoted time .

already u share a lot of things to us , thanks a lot for that sir......
 

pratapvb

Well-Known Member
takes too much time ...as have to 1st understand the logic of prev code....will see if I have time
 
you should think of all variables as arrays

also for loop on all bars should be avoided at all cost...it is mostly not necessary....also it makes AFL slow

check all the code that I have posted here....how many for loops are there? some text labeling related for loops are there but even that is restricted to only visible bars...but main algorithm is mostly without for loops
You need to be "balanced" about Loops. Speed impact caused by loops is barely significant and hence not a great reason against loops. Loop is one of the critical and fundamental building block of programming world. "for" became part of standard keyword in many languages since Structured Programming Paradigm defined in 1970s.

In Truth, Loop in Amibroker is double edged sword....

AFL code using loop can be more easily edited to work with other software such as Ninja or MT4 (C++ based world). Concept of array without explicit indices as single variables is not easy to comprehend.

Conversely, writing without loops in Ami makes code appear smaller at first glance but that does not actually mean you've managed something without loop. There are ample instances in which each line of AFL may end up with its own loop that is managed internally and merely being hidden from you.

If you are keen to figure out whether or not looped version is faster or slower simply enable "Display Chart Timing" in preferences and AMI will show runtime stats on left hand side of chart,
 
Last edited:
I see a blank window when Exploring and Error (Sell/Cover are not defined) when backtesting. Please explain what you are looking for.
Thank you for responding.

The code generates buy/signal in realtime while exploring.(today if u explore for nifty 50 stocks in 30tf it generated a sell in SSLT scrip).

I want to back test this system for at least 3 yrs.
This is the first code I hv written so I am not sure how to write sell/cover/applystop conditions.( I hv written a apply stop condn in the afl, pls say whether it is right or wrong.)

Can you pls write the sell/cover condn?

I risk 1% of my equity as SL and sell/cover if I gain 1% of my equity. R:R is 1:1.

I tried to backtest adding sell = 0; cover = 0; and in the backtest settings >>stops>> enable stop and profit mode 1%.

But I am not getting the correct result.

So with the abv said sell/cover condition can u pls backtest or guide me to backtest?

Thanks. Hope I am clear atleast now. If you want I will upload a chart.
 

pratapvb

Well-Known Member
You need to be "balanced" about Loops. Speed impact caused by loops is barely significant and hence not a great reason against loops. Loop is one of the critical and fundamental building block of programming world. "for" became part of standard keyword in many languages since Structured Programming Paradigm defined in 1970s.

In Truth, Loop in Amibroker is double edged sword....

AFL code using loop can be more easily edited to work with other software such as Ninja or MT4 (C++ based world). Concept of array without explicit indices as single variables is not easy to comprehend.

Conversely, writing without loops in Ami makes code appear smaller at first glance but that does not actually mean you've managed something without loop. There are ample instances in which each line of AFL may end up with its own loop that is managed internally and merely being hidden from you.

If you are keen to figure out whether or not looped version is faster or slower simply enable "Display Chart Timing" in preferences and AMI will show runtime stats on left hand side of chart,
I don't know about portability issue as I have not worked with other trading s/w. and I am also aware that functions like AMA maybe using for loop internally, but this is expected to be better optimized by ami.

And I know the value of 'for' as a programming construct. I was 20+ years in IT and have lead teams and designed for complex s/w like medical ultrasound m/c s/w, Smart card systems and the like.

array programming maybe diff to understand, that is why I said that to write better programmes that thinking needs to come in and where array programming option is available, I will still continue to avoid loops
 
Last edited:

pratapvb

Well-Known Member

Similar threads