Sounds like you might want to put everything into one script. If so, the example below should get you started (though it uses a CSV file).
Do 'File > New > New Script' to open a window, copy the code below, and paste it in. You can run it as it is (with 'Edit > Run Script'), and then adapt it to your case. Do 'File > Save' to save your new script file.
To learn a little about JSL, try 'Help > Books > Scripting Guide'.
Names Default To Here( 1 );
// Read in a sample csv file
dt = Open( "$SAMPLE_IMPORT_DATA/Book1.csv" );
// Add a formula column
dt <<
// To get this code, build your formula 'by hand', then do 'File > New > New Script',
// type the command 'columnRef << getScript', and then 'Edit > Run Script'. Then look
// immediately below or in 'Window > Log' to get the result. In this case, the command
// was: ':Formula << getScript'.
New Column( "Formula", Numeric, "Continuous", Formula( (:Name( "1" ) + :Name( "2" )) / :Name( "3" ) ) );
// Now use Graph Builder 'by hand', and get the JSL code it makes for you . . .
dt <<
// . . . and paste it here
Graph Builder(
Size( 531, 452 ),
Show Control Panel( 0 ),
Variables( X( :Name( "1" ) ), Y( :Formula ) ),
Elements( Points( X, Y, Legend( 6 ) ), Smoother( X, Y, Legend( 7 ) ) )
);