Working on automating The Holy Grail & Sharky's method - futures io
futures io futures trading



Working on automating The Holy Grail & Sharky's method


Discussion in NinjaTrader

Updated by wolfsch
      Top Posters
    1. looks_one RBSailing with 5 posts (1 thanks)
    2. looks_two wolfsch with 4 posts (0 thanks)
    3. looks_3 BigDog with 3 posts (0 thanks)
    4. looks_4 MXASJ with 2 posts (0 thanks)
    1. trending_up 5,536 views
    2. thumb_up 1 thanks given
    3. group 4 followers
    1. forum 15 replies
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • 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 and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Working on automating The Holy Grail & Sharky's method

(login for full post details)
  #1 (permalink)
Chicago
 
 
Posts: 60 since Jun 2009
Thanks: 0 given, 17 received

If i have an indicator that only paints bars, is it possible to pull that code into a strategy such that I can generate buy/sell signals from it?

I'm trying to automate these two strategies since everyone seems to have good experience (figure why can't this be automated...) adding in some position sizing, unwinding positions faster as risk is built up, etc etc

Trying to start with ADXVMA_sharky indicator... right now it only paints the adx line red/blue/yellow from my understanding...

what I want to implement is when red... sell, when blue... buy, when yellow... do nothing...

(from there on will build on the other indicators)

 
Code
protected override void OnBarUpdate()
{
    if( CurrentBar < 2 )
    {
        PDM.Set( 0 );
        MDM.Set( 0 );
        PDI.Set( 0 );
        MDI.Set( 0 );
        Out.Set( 0 );
        Main.Set( 0 );
        Rising.Set( 0 );
        Falling.Set( 0 );
        Neutral.Set( 0 );
        return;
    }
    try
    {
        int i = 0;
        PDM.Set( 0 );
        MDM.Set( 0 );
        if(Close[i]>Close[i+1])
            PDM.Set( Close[i]-Close[i+1] );//This array is not displayed.
        else
            MDM.Set( Close[i+1]-Close[i] );//This array is not displayed.
        
        PDM.Set(((WeightDM-1)*PDM[i+1] + PDM[i])/WeightDM);//ema.
        MDM.Set(((WeightDM-1)*MDM[i+1] + MDM[i])/WeightDM);//ema.
        
        double TR=PDM[i]+MDM[i];
        
        if (TR>0)
        {
            PDI.Set(PDM[i]/TR);
            MDI.Set(MDM[i]/TR);
        }//Avoid division by zero. Minimum step size is one unnormalized price pip.
        else
        {
            PDI.Set(0);
            MDI.Set(0);
        }
        
        PDI.Set(((WeightDI-1)*PDI[i+1] + PDI[i])/WeightDI);//ema.
        MDI.Set(((WeightDI-1)*MDI[i+1] + MDI[i])/WeightDI);//ema.

        double DI_Diff=PDI[i]-MDI[i];  
        if (DI_Diff<0)
            DI_Diff= -DI_Diff;//Only positive momentum signals are used.
        double DI_Sum=PDI[i]+MDI[i];
        double DI_Factor=0;//Zero case, DI_Diff will also be zero when DI_Sum is zero.
        if (DI_Sum>0)
            Out.Set(DI_Diff/DI_Sum);//Factional, near zero when PDM==MDM (horizonal), near 1 for laddering.
        else
            Out.Set(0);

          Out.Set(((WeightDX-1)*Out[i+1] + Out[i])/WeightDX);
        
        if (Out[i]>Out[i+1])
        {
            HHV=Out[i];
            LLV=Out[i+1];
        }
        else
        {
            HHV=Out[i+1];
            LLV=Out[i];
        }

        for(int j=1;j<Math.Min(ADXPeriod,CurrentBar);j++)
        {
            if(Out[i+j+1]>HHV)HHV=Out[i+j+1];
            if(Out[i+j+1]<LLV)LLV=Out[i+j+1];
        }
        
        
        double diff = HHV - LLV;//Veriable reference scale, adapts to recent activity level, unnormalized.
        double VI=0;//Zero case. This fixes the output at its historical level. 
        if (diff>0)
            VI=(Out[i]-LLV)/diff;//Normalized, 0-1 scale.
        
        //   if (VI_0.VIsq_1.VIsqroot_2==1)VI*=VI;
        //   if (VI_0.VIsq_1.VIsqroot_2==2)VI=MathSqrt(VI);
        //   if (VI>VImax)VI=VImax;//Used by Bemac with VImax=0.4, still used in vma1 and affects 5min trend definition.
                                //All the ema weight settings, including Chande, affect 5 min trend definition.
        //   if (VI<=zeroVIbelow)VI=0;                    
                                
        main.Set(((ChandeEMA-VI)*main[i+1]+VI*Close[i])/ChandeEMA);//Chande VMA formula with ema built in.
        if (main[0] > main[1])
        { Rising.Set(main[0]); Rising.Set(1, main[1]); }
        else if (main[0] < main[1])
        { Falling.Set(main[0]); Falling.Set(1, main[1]); }
        else
        { Neutral.Set(main[0]); Neutral.Set(1, main[1]); }
    }
    catch( Exception ex )
    {
        Print( ex.ToString() );
    }
}
i've bold faced and underlined the area I believe would set the conditions....

any ideas on how this could be done?

Reply With Quote

Can you help answer these questions
from other members on futures io?
Sending an ACH from BoA to GFF Brokers
Brokers
Can anyone help convert this pine script to c# or vb?
MultiCharts
US OTCQB STOCK Brooker for UK BASED RESIDENT
Brokers
Traderoomplus
Trading Reviews and Vendors
MulitCharts: Limit Order converted to MIT
Platforms and Indicators
 
 
(login for full post details)
  #2 (permalink)
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 799 received

Consider trying some logic like this:

if adxvma rising = true for a certain number of bars // do something long
if adxvma falling = true for a certain number of bars // do something short

Also look at price > adxvma for longs, opposite for shorts
Also look at adxvma main > signal for longs, opposite for shorts

Good luck!

Reply With Quote
 
(login for full post details)
  #3 (permalink)
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 799 received


if (Close[0] >= ADXVMA_sharky_paint(6, true).Main[0]
&& Close[
1] >= ADXVMA_sharky_paint(6, true).Main[1]
&& ADXVMA_sharky_paint(
6, true).Main[0] > ADXVMA_sharky_paint(6, true).Main[1]
&& ADXVMA_sharky_paint(
6, true).Main[1] > ADXVMA_sharky_paint(6, true).Main[2]

// more conditions and go LONG

Is part of the conditions for the LONG side of strat I've been testing recently. It looks for a two bar trend confirmation. Not the fastest, but worth considering.

Reply With Quote
 
(login for full post details)
  #4 (permalink)
Chicago
 
 
Posts: 60 since Jun 2009
Thanks: 0 given, 17 received

should have updated earlier... figured it out... i'm a doofus!

was very easy to implement just by simply calling the indicator into the strategy...


going to go through the thread again later tonite to see the specific conditions that = true in order to enter a trade for either strategy...


or if someone once to be a champion and post the exact conditions that'll make life much easier.... have much of the money management logic in place...

running a random entry for the money management nets positive edge, so that much does look good (was tested on 12000+ trades)

Reply With Quote
 
(login for full post details)
  #5 (permalink)
USA
 
Experience: Beginner
Platform: NinjaTrader
 
Posts: 26 since Jul 2009
Thanks: 4 given, 17 received

Hi BigDog,

What money management do you use?

Thanks,

Yuval.

Reply With Quote
 
(login for full post details)
  #6 (permalink)
Chicago
 
 
Posts: 60 since Jun 2009
Thanks: 0 given, 17 received


YuvalW View Post
Hi BigDog,

What money management do you use?

Thanks,

Yuval.


scaling, selling or buying more agressively as building up risk, constantly working bids/asks etc

Reply With Quote
 
(login for full post details)
  #7 (permalink)
Palm Beach Gardens
 
Experience: Intermediate
Platform: Ninja Trader
 
RBSailing's Avatar
 
Posts: 21 since Jun 2009
Thanks: 5 given, 6 received

I have been using the ADXVMA in a strategy too. I added a a MAslope data series to the indicator, made it a public data series. Then the strat just checks the value ( I used a -1 = negative, 0 = flat , 1 = positive slope) of the data series for the bar you are interested in.

When checking that actual "price" value of the plotted line of an indicator I use the simpler version ie non paint. I think it uses less system resources.

In a strategy that has multiple entry conditions I like to create variables in the strategy that I then set at the beginning of the OnBarUpdate based on the relevant indicator states at that bar. Then instead of calling the indicators over and over I just check the variables.

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #8 (permalink)
waiblingen Germany
 
Experience: Intermediate
Platform: ninja, Meta 4
Broker: Mirus Zenfire
Trading: ES, forex
 
Posts: 49 since Jul 2009
Thanks: 7 given, 3 received

Hi RBSailing , you mention a MASlope which I am looking for to work with the TripleEMA with 2 diiferent length, using the longer one as a filter. How can I get an indicator transformed to have the slope? I would like to have a general script to input in different indies. Have you an idea how to do?
Thanks Wolfsch

Reply With Quote
 
(login for full post details)
  #9 (permalink)
Hartford, CT. USA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG, Kinetick
Trading: RTY
 
RJay's Avatar
 
Posts: 686 since Jun 2009
Thanks: 747 given, 775 received


BigDog View Post
If i have an indicator that only paints bars, is it possible to pull that code into a strategy such that I can generate buy/sell signals from it?

I'm trying to automate these two strategies since everyone seems to have good experience (figure why can't this be automated...) adding in some position sizing, unwinding positions faster as risk is built up, etc etc

Trying to start with ADXVMA_sharky indicator... right now it only paints the adx line red/blue/yellow from my understanding...

what I want to implement is when red... sell, when blue... buy, when yellow... do nothing...

(from there on will build on the other indicators)

 
Code
protected override void OnBarUpdate()
{
    if( CurrentBar < 2 )
    {
        PDM.Set( 0 );
        MDM.Set( 0 );
        PDI.Set( 0 );
        MDI.Set( 0 );
        Out.Set( 0 );
        Main.Set( 0 );
        Rising.Set( 0 );
        Falling.Set( 0 );
        Neutral.Set( 0 );
        return;
    }
    try
    {
        int i = 0;
        PDM.Set( 0 );
        MDM.Set( 0 );
        if(Close[i]>Close[i+1])
            PDM.Set( Close[i]-Close[i+1] );//This array is not displayed.
        else
            MDM.Set( Close[i+1]-Close[i] );//This array is not displayed.
        
        PDM.Set(((WeightDM-1)*PDM[i+1] + PDM[i])/WeightDM);//ema.
        MDM.Set(((WeightDM-1)*MDM[i+1] + MDM[i])/WeightDM);//ema.
        
        double TR=PDM[i]+MDM[i];
        
        if (TR>0)
        {
            PDI.Set(PDM[i]/TR);
            MDI.Set(MDM[i]/TR);
        }//Avoid division by zero. Minimum step size is one unnormalized price pip.
        else
        {
            PDI.Set(0);
            MDI.Set(0);
        }
        
        PDI.Set(((WeightDI-1)*PDI[i+1] + PDI[i])/WeightDI);//ema.
        MDI.Set(((WeightDI-1)*MDI[i+1] + MDI[i])/WeightDI);//ema.

        double DI_Diff=PDI[i]-MDI[i];  
        if (DI_Diff<0)
            DI_Diff= -DI_Diff;//Only positive momentum signals are used.
        double DI_Sum=PDI[i]+MDI[i];
        double DI_Factor=0;//Zero case, DI_Diff will also be zero when DI_Sum is zero.
        if (DI_Sum>0)
            Out.Set(DI_Diff/DI_Sum);//Factional, near zero when PDM==MDM (horizonal), near 1 for laddering.
        else
            Out.Set(0);

          Out.Set(((WeightDX-1)*Out[i+1] + Out[i])/WeightDX);
        
        if (Out[i]>Out[i+1])
        {
            HHV=Out[i];
            LLV=Out[i+1];
        }
        else
        {
            HHV=Out[i+1];
            LLV=Out[i];
        }

        for(int j=1;j<Math.Min(ADXPeriod,CurrentBar);j++)
        {
            if(Out[i+j+1]>HHV)HHV=Out[i+j+1];
            if(Out[i+j+1]<LLV)LLV=Out[i+j+1];
        }
        
        
        double diff = HHV - LLV;//Veriable reference scale, adapts to recent activity level, unnormalized.
        double VI=0;//Zero case. This fixes the output at its historical level. 
        if (diff>0)
            VI=(Out[i]-LLV)/diff;//Normalized, 0-1 scale.
        
        //   if (VI_0.VIsq_1.VIsqroot_2==1)VI*=VI;
        //   if (VI_0.VIsq_1.VIsqroot_2==2)VI=MathSqrt(VI);
        //   if (VI>VImax)VI=VImax;//Used by Bemac with VImax=0.4, still used in vma1 and affects 5min trend definition.
                                //All the ema weight settings, including Chande, affect 5 min trend definition.
        //   if (VI<=zeroVIbelow)VI=0;                    
                                
        main.Set(((ChandeEMA-VI)*main[i+1]+VI*Close[i])/ChandeEMA);//Chande VMA formula with ema built in.
        if (main[0] > main[1])
        { Rising.Set(main[0]); Rising.Set(1, main[1]); }
        else if (main[0] < main[1])
        { Falling.Set(main[0]); Falling.Set(1, main[1]); }
        else
        { Neutral.Set(main[0]); Neutral.Set(1, main[1]); }
    }
    catch( Exception ex )
    {
        Print( ex.ToString() );
    }
}
i've bold faced and underlined the area I believe would set the conditions....

any ideas on how this could be done?

Hey BigDog,

I think this strategy is possible. Just one huge problem!!!

This indicator code you are using is repainting the last bar!!!

Check all code lines and do the following.

if the code line updates for both current bar and previous bar like this...

{ Rising.Set(main[0]); Rising.Set(1, main[1]); }

Simply comment out the update to the previous bar like this...

{ Rising.Set(main[0]); // Rising.Set(1, main[1]); }

As far as the strategy goes, when you select this indicator, select indicator output field.

Select each output for each condition. if condition => 1 ( Buy, sell, or do nothing.)

Let me know how it goes,

RJay

Reply With Quote
 
(login for full post details)
  #10 (permalink)
Palm Beach Gardens
 
Experience: Intermediate
Platform: Ninja Trader
 
RBSailing's Avatar
 
Posts: 21 since Jun 2009
Thanks: 5 given, 6 received



wolfsch View Post
Hi RBSailing , you mention a MASlope which I am looking for to work with the TripleEMA with 2 diiferent length, using the longer one as a filter. How can I get an indicator transformed to have the slope? I would like to have a general script to input in different indies. Have you an idea how to do?
Thanks Wolfsch

There is an indicator in the download section
ColorSampleUniversalMovingAverage
That should do the job for you. I am not sure the exact algorithm they use. I will look at it and posagain. I modified the slope angle calculation that I think originate at NT forum. That calculation averaged the indicator value of the last 2 bars and then compared it to the current value. I removed the averaging so I just check the slope form the last bar to the current bar.
Have you lookad at the LinReg Ma?

Follow me on Twitter Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > Working on automating The Holy Grail & Sharky's method


January 21, 2010


Upcoming Webinars and Events
 

Order Flow Tools w/MotiveWave & Zytrade Brokerage

Oct 22
 

Technical Analysis Workshop w/NinjaTrader

Oct 27
 

Bookmap

Oct TBD
 

SharkIndicators

Oct TBD
 

Carley Garner

Oct TBD
 

GruttePier

Oct TBD
     



Copyright © 2020 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts