Simple Coding Help - No Promise.

@bbhanushali ,

Hi Bro,

Need your assistance on this one. I am aware (learnt from the net) that using the ExRem command helps to avoid repetition of the same signals for the scrip. But what if there is no Buy or Sell conditions. In the following code we just have Accumulation Distribution printed on exploration :

//Wad: Larry Williams Acc/Distribution Status
TRH = IIf(Ref(C, -1) > H, Ref(C, -1), H);
TRL = IIf(Ref(C, -1) < L, Ref(C, -1), L);
ad = IIf(C > Ref(C, -1), C - TRL, IIf(C < Ref(C, -1), C - TRH, 0));
WAD = Cum(ad);
wu = wad > Ref(wad,-1);
wd = wad < Ref(wad,-1);
wad_status= WriteIf(wu, "Rising", WriteIf(wd, "Falling", "Neutral"));
wad_Col=IIf(wu, colorGreen, IIf(wd, colorRed, colorLightGrey));
//Exploration
AddTextColumn(ad_status, "Acc/Dist", 1, colorWhite, ad_Col);

Want to know couple of things :
(1) One is to avoid repetition for sure
(2) In addition in this case there is a color component as well. For e.g., if the conditions are not met per the code above, then default color is Grey.
In essence, what I want is, I want the exploration to print only Green or Red conditions, I guess we can do this by just removing the colorLightGrey and leave it with colorGreen, colorRed (guess common sense :)). But in addition, what I am looking for is, if the condition is met, I do not want to the print to repeat unless there is a change. Is this possible with the ExRem command ?

Thank you so much for your help, in advance.

Warm Regards
JS
JediStar Sir, Hope this is right as you wanted! Thanks.

Code:
_SECTION_BEGIN("Accummulation Distribution Exploration");

//I do not want to the print to repeat unless there is a change.

//Wad: Larry Williams Acc/Distribution Status
TRH = IIf(Ref(C, -1) > H, Ref(C, -1), H);
TRL = IIf(Ref(C, -1) < L, Ref(C, -1), L);
ad = IIf(C > Ref(C, -1), C - TRL, IIf(C < Ref(C, -1), C - TRH, 0));
WAD = Cum(ad);
wu = wad > Ref(wad,-1);
wd = wad < Ref(wad,-1);

wu = ExRem(wu,wd);
wd = ExRem(wd,wu);

wad_status= WriteIf(wu, "Rising", WriteIf(wd, "Falling", "Neutral"));
wad_Col=IIf(wad_status == "Rising", colorGreen, IIf(wad_status == "Falling", colororange, colorLightGrey));

//=======================

Buy = wu;
Short = wd;
Sell = Cover = Null;
short= sell; cover= buy;


per10 = Param( "Trade Entry From(HHMM)", 1000, 900, 2300, 1 );
per11 = Param( "Trade Entry Upto(HHMM)", 1430, 900, 2300, 1 );
per12 = Param( "Trade Exit(HHMM)", 1515, 900, 2300, 100 );
sl = Param( "StopLoss(Rs.)", 0, 0, 1000, 0.1 );
tgt = Param( "Target(Rs.)", 0, 0, 1000, 0.1 );
intra = ParamToggle( "Activate Intraday Mode", "NO|YES",0 );

intraex = intra AND TimeNum() > per12 * 100;
intraen = !intra OR ( TimeNum() < per11 * 100 AND TimeNum() > per10 * 100 );

Col = ParamColor( "Color of Signals", colorBlack );


Buy1 = Buy;
Sell1 = Sell;
Short1 = Short;
Cover1 = Cover;
bflag = sflag = 0;
slarr = tgtarr = Null;

for ( i = 10; i < BarCount; i++ )
{
    if ( Buy1[i] AND intraen[i] AND bflag == 0 )
    {
        Buy[i] = 1;
        bflag = 1;

        if ( sl )
            slarr[i] = C[i] - sl;

        if ( tgt )
            tgtarr[i] = C[i] + tgt;
    }
    else
        Buy[i] = 0;

    if ( bflag AND Buy[i] == 0 )
    {
        slarr[i] = slarr[i-1];
        tgtarr[i] = tgtarr[i-1];
    }

    if ( ( Sell1[i] OR intraex[i] OR( L[i] < slarr[i-1] AND sl > 0 ) OR ( H[i] > tgtarr[i] AND tgt > 0 ) ) AND bflag )
    {
        Sell[i] = 1;
        bflag = 0;
    }
    else
        Sell[i] = 0;

    if ( Short1[i] AND intraen[i] AND sflag == 0 )
    {
        Short[i] = 1;
        sflag = 1;

        if ( sl )
            slarr[i] = C[i] + sl;

        if ( tgt )
            tgtarr[i] = C[i] - tgt;
    }
    else
        Short[i] = 0;

    if ( sflag AND Short[i] == 0 )
    {
        slarr[i] = slarr[i-1];
        tgtarr[i] = tgtarr[i-1];
    }

    if ( ( Cover1[i] OR intraex[i]OR( H[i] > slarr[i-1] AND sl > 0 )  OR ( L[i] < tgtarr[i] AND tgt > 0 ) ) AND sflag )
    {
        Cover[i] = 1;
        sflag = 0;
    }
    else
        Cover[i] = 0;
}

Filter= Buy OR Sell OR Short OR Cover;


//=======================

//Exploration

AddTextColumn(wad_status, "Acc/Dist", 1, colorWhite, wad_Col);

_SECTION_END();
 
Have a weird question for the experts. While exploring once the clock strikes 1:00 PM, the exploration data gets below the 12 Noon Timestamp.
What can be done to make sure the latest is on the top like changing the TF format to 13:00 hours. How can we do this in Amibroker ?
JediStar Sir,
1. Click on the Windows 10 Start button and select Settings.
2. Click on "Time and Language".
3. Next, click on the "Change date and time formats".
4. On the next screen, click on "Short Time" and pick H:mm from the drop-down choices. Next, click on "Long Time" and choose H:mm:ss from the drop-down.

Short Time : h:mm tt – Change this to H:mm
Long Time: h:mm:ss tt – Change this to H:mm:ss

5. Once you have selected the 24 hour time format (any choice with a capital ‘H’), just close the settings window. The change will be reflected immediately on both Long and Short time locations of your computer.

6. Now Run your explorations in Amibroker and they will be in proper ascending or descending order of time as selected.

Thanks
 
@bbhanushali
sir i am following you on traderji and liked your valuable work...
can you make scanner afl for below condition.
stocks trading 1,2 and 3 month near high and near low...i am telling near high and low not exact high and low.
thanks in advance.
Raj_Jain1 Sir, If you have afl for the conditions you mentioned which plots signal on chart then I can modify and add exploration to it. .Also, do provide some picture snap shots of what you are looking in exploration. My apologies Sir, but I am a lousy creator i.e. I am only doing some cut paste jobs and learning while on the go. Many thanks for your query.
 
@bbhanushali,

Hello there, Got a couple of queries, though you continue to belittle your intelligence in coding :) (no pun intended) :

(1) Why on earth is the amibroker charts looks pathetic, I mean, the moment you add a couple of indicators to the chart, the chart starts looking like a spaghetti..... even magnified glasses wont help decipher what you see on the screen. I am sure we all agree indicators are there to be added to the chart :). Is there a way to have charts like Meta Trader, where the view is crisp and clear (I understand limitations there). On the same lines, why is that when you add a indicator remove add another, the chart (I mean the whole view of the page) really gets messed up. Is this by design as MT4 is far better.

(2) Now issue with MT4. The time displayed on the charts is always -30 Minutes, and I have tried different data feed provider but the issue remains the same. Is there a way that we can have MT4 charts display the computer time.

I know these are lame questions, but my search did not give me any answer and hence posting here :).
 
(1) Why on earth is the amibroker charts looks pathetic, I mean, the moment you add a couple of indicators to the chart, the chart starts looking like a spaghetti..... even magnified glasses wont help decipher what you see on the screen. I am sure we all agree indicators are there to be added to the chart :). Is there a way to have charts like Meta Trader, where the view is crisp and clear (I understand limitations there). On the same lines, why is that when you add a indicator remove add another, the chart (I mean the whole view of the page) really gets messed up. Is this by design as MT4 is far better.

(2) Now issue with MT4. The time displayed on the charts is always -30 Minutes, and I have tried different data feed provider but the issue remains the same. Is there a way that we can have MT4 charts display the computer time.

I know these are lame questions, but my search did not give me any answer and hence posting here :).
Sorry to intervene!
To hold and appreciate a beautiful rose you need to bear its thorns.
Have you read the AmiBroker's User Manual before making such claims?
Have you tried and experimented with atleast 15 Knowledge Base examples (if not all)?
There is nothing second to AmiBroker's speed, adaptability, flexibility and user-friendliness PERIOD
Yes it is not easy but not that difficult either if you are really interested to delve deep.
 

Similar threads